/**
 * @param totalCounts 总行
 * @param totalPages  总页
 * @param currentPageNo 当前页
 * 
 * @使用说明  
 * 1、引入 /css/pagnation.css 如果其它css文件中已包含不引入，
 * 2、所在页面须有 <div class="pagnation" id="pagnation"></div>
 */
function pagnation(totalCounts,totalPages,currentPageNo){
	var pagnation = $("#pagnation");
	var pagnationHtml = "";
	var pagePrevHtml = "";
	var pageNextHtml = "";
	var pageNumberHtml = "";
	pagnationHtml += "<span class=\"pageDown-sum\"><em>共<i>"+totalCounts+"</i>条记录</em><em>当前第 <i>"+currentPageNo+"</i>页 </em><i>/</i>共<i> "+totalPages+"</i>页</span>";
	if(totalPages > 0)
	{
		if(currentPageNo == 1)
		{
			pagePrevHtml = "<a class=\"page-prev\">上一页</a>";
			//总页码为 1，禁止下一页
			if(totalPages==1)
			{
				pageNextHtml = "<a class=\"page-next\">下一页</a>";
			}else{
				pageNextHtml = "<a href=\"javascript:goPage("+parseInt(currentPageNo+1)+")\" class=\"page-next\">下一页</a>";	
			}
		}else if(currentPageNo < totalPages){
			pagePrevHtml = "<a href=\"javascript:goPage("+parseInt(currentPageNo-1)+")\" class=\"page-prev\">上一页</a>";
			pageNextHtml = "<a href=\"javascript:goPage("+parseInt(currentPageNo+1)+")\" class=\"page-next\">下一页</a>";
		}else if(currentPageNo == totalPages){
			pagePrevHtml = "<a href=\"javascript:goPage("+parseInt(currentPageNo-1)+")\" class=\"page-prev\">上一页</a>";
			pageNextHtml = "<a class=\"page-next\">下一页</a>";
		}
		//总页码 <7
		if(totalPages < 7){
			for(var i = 0 ; i < totalPages ; i++){
				var currentClass = "";
				if((i+1) == currentPageNo){
					currentClass = "class = \"current\"";
				}
				pageNumberHtml += "<a href=\"javascript:goPage("+parseInt(i+1)+")\" "+currentClass+">"+(i+1)+"</a>";
			}
		}else{
			//判断是否后几页
			if(totalPages - currentPageNo - 4 > 0){
				var start = 0,end = 0;
				if(currentPageNo  < 3){
					start = 0;end = 6;
				}else{
					start = currentPageNo - 3 ; end = currentPageNo + 3;
				}
				for(var i = start ; i < end ; i++){
					var currentClass = "";
					if((i+1) == currentPageNo){
						currentClass = "class = \"current\"";
					}
					pageNumberHtml += "<a href=\"javascript:goPage("+parseInt(i+1)+")\" "+currentClass+">"+(i+1)+"</a>";
				}
				pageNumberHtml += "<span class=\"page-items\">...</span>";
				pageNumberHtml += "<a href=\"javascript:goPage("+totalPages+")\" >"+totalPages+"</a>";
			}else{
				pageNumberHtml += "<a href=\"javascript:goPage(1)\" >1</a>";
				pageNumberHtml += "<span class=\"page-items\">...</span>";
				for(var i =totalPages - 6 ; i < totalPages ; i++){
					var currentClass = "";
					if((i+1) == currentPageNo){
						currentClass = "class = \"current\"";
					}
					pageNumberHtml += "<a href=\"javascript:goPage("+parseInt(i+1)+")\" "+currentClass+">"+(i+1)+"</a>";
				}
			}
		}
		pagnation.html(pagnationHtml + pagePrevHtml + pageNumberHtml + pageNextHtml);
	}else{
		
		pagnation.html("<font color='red' size='+1'>没有要显示的数据</font>");
	}
}
